package com.example.httphostname;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.net.InetAddress;

@RestController
@SpringBootApplication
public class HttphostnameApplication {
    private static final Logger log = LoggerFactory.getLogger(HttphostnameApplication.class);

    public static void main(String[] args) {
        SpringApplication.run(HttphostnameApplication.class, args);
        log.error("**************logger error******************");
    }
        @GetMapping("host")
        public String host () {
            String host = null;
            try {
                host = InetAddress.getLocalHost().getHostName();
            } catch (Exception e) {
                //打印堆栈信息
                e.printStackTrace();
            }
            return host;
        }
}

